function calcNextPoint( pos,ppos )
	for i=1,#ppos-1 do
		--先比较横坐标
		if (pos<ppos[i] and pos>ppos[i+1]) or (pos>ppos[i] and pos<ppos[i+1]) then
			return ppos[i+1]
		end
	end
end

local function dump_value_(v)
    if type(v) == "string" then
        v = "\"" .. v .. "\""
    end
    return tostring(v)
end
function dump(value, desciption, nesting)
    if type(nesting) ~= "number" then nesting = 3 end

    local lookupTable = {}
    local result = {}

    local function dump_(value, desciption, indent, nest, keylen)
        desciption = desciption or "<var>"
        local spc = ""
        if type(keylen) == "number" then
            spc = string.rep(" ", keylen - string.len(dump_value_(desciption)))
        end
        if type(value) ~= "table" then
            result[#result +1 ] = string.format("%s%s%s = %s", indent, dump_value_(desciption), spc, dump_value_(value))
        elseif lookupTable[tostring(value)] then
            result[#result +1 ] = string.format("%s%s%s = *REF*", indent, dump_value_(desciption), spc)
        else
            lookupTable[tostring(value)] = true
            if nest > nesting then
                result[#result +1 ] = string.format("%s%s = *MAX NESTING*", indent, dump_value_(desciption))
            else
                result[#result +1 ] = string.format("%s%s = {", indent, dump_value_(desciption))
                local indent2 = indent.."    "
                local keys = {}
                local keylen = 0
                local values = {}
                for k, v in pairs(value) do
                    keys[#keys + 1] = k
                    local vk = dump_value_(k)
                    local vkl = string.len(vk)
                    if vkl > keylen then keylen = vkl end
                    values[k] = v
                end
                table.sort(keys, function(a, b)
                    if type(a) == "number" and type(b) == "number" then
                        return a < b
                    else
                        return tostring(a) < tostring(b)
                    end
                end)
                for i, k in ipairs(keys) do
                    dump_(values[k], k, indent2, nest + 1, keylen)
                end
                result[#result +1] = string.format("%s}", indent)
            end
        end
    end
    dump_(value, desciption, "- ", 1)

    for i, line in ipairs(result) do
        print(line)
    end
end

local GameRules = {}
GameRules.diffSelect = {}
local config = {}
function C2S_DIFF_SELECT( event,data )
	local diff = data.diff
	local mode = data.mode
	local id = data.PlayerID
	if GameRules.diffSelect[id+1] then
		return
	end
	GameRules.diffSelect[id+1] = {diff=diff,mode=mode}
	local send = {diff={},mode={}}
	for i,v in ipairs(GameRules.diffSelect) do
		if not send.diff[v.diff] then
			send.diff[v.diff] = 1
		else
			send.diff[v.diff] = send.diff[v.diff] + 1
		end
		if not send.mode[v.mode] then
			send.mode[v.mode] = 1
		else
			send.mode[v.mode] = send.mode[v.mode] + 1
		end
	end
	
end

function CompletedDiffSelect(  )
	local send = {diff={},mode={}}
	for i,v in ipairs(GameRules.diffSelect) do
		if not send.diff[v.diff] then
			send.diff[v.diff] = 1
		else
			send.diff[v.diff] = send.diff[v.diff] + 1
		end
		if not send.mode[v.mode] then
			send.mode[v.mode] = 1
		else
			send.mode[v.mode] = send.mode[v.mode] + 1
		end
	end
	dump(send)
	local diff = 1
	local mode = 1
	local val1 = 0
	local val2 = 0
	for k,v in pairs(send.diff) do
		if v>val1 then
			diff = k
			val1 = v
		end
	end
	for k,v in pairs(send.mode) do
		if v> val2 then
			mode = k
			val2 = v
		end
	end
	
	local gold_add = 100*(diff-1) + 200
	for i=0,3 do
		print(gold_add,i)
	end
	GameRules.diff = diff
	config = {
		diff = diff,
		mode = mode,
	}
	dump(config)
	-- Notifications:TopToAll({text="diff_selected", style={color='#E62020'}, duration=6})
	-- Notifications:TopToAll({text="diff"..diff, style={color='#E62020'}, duration=6,continue=true})
	-- EmitGlobalSound("Hero_Silencer.GlobalSilence.Effect")
	
	--CustomGameEventManager:Send_ServerToAllClients("refresh_diff",{diff=diff})
end


function aaa(q )
	local fmt = "([%a]*)[_%d]-"
	local name1 = "yamanren1"
local name2 = "yamanren12"
local name3 = "yamanren1_3"
local w = {name1,name2,name3}
for i,v in ipairs(w) do
	print(v:match(fmt))
end
end
aaa()